﻿using RMM.Orders;
using RMM.Orders.Dtos;
using Swashbuckle.Swagger.Annotations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;

namespace RMM.Web.Controllers
{
    public class OrderController : RMMControllerBase
    {
        private readonly IOrderAppService _orderAppService;

        public OrderController(IOrderAppService orderAppService)
        {
            _orderAppService = orderAppService;
        }

        [HttpGet]
        public async Task<JsonResult> GetOrderAsync(string orderCode)
        {
            var result = await _orderAppService.GetOrderAsync(orderCode);
            return Json(result);
        }

        [HttpPost]
        public async Task<JsonResult> CreateOrderAsync(CreateOrderDto createOrderDto)
        {
            var result = await _orderAppService.CreateOrderAsync(createOrderDto);
            return Json(result);
        }
    }
}